import { useState } from "react"; 
import constate from "constate"; 
 
// custom hook 
function useCounter() { 
  const [count, setCount] = useState(0); 
  const increment = () => setCount(prevCount => prevCount + 1); 
  const decrement = () => setCount(prevCount => prevCount - 1); 
  return { count, increment, decrement}; 
} 
 
// hook passed in constate 
export const [CounterProvider, useCounterContext] = constate(useCounter); 